package com.smartleanx.module.hrm.eums.employee;

import com.smartleanx.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 材料附件类型枚举
 *
 * @author tengcj
 * @since 2024/5/17
 */
@Getter
@AllArgsConstructor
public enum BizFileTypeEnum implements IntArrayValuable {

    // ==================员工入职资料=========================
    /**
     * 合同
     */
    CONTRACT(1001, "合同", false, 1, "icon"),
    /**
     * 身份证
     */
    ID_CARD(1002, "身份证原照片", true, 1, "fa:address-card-o"),
    /**
     * 学历证明
     */
    EDUCATION_PROOF(1003, "学历证明", true, 1, "fa-solid:user-graduate"),
    /**
     * 个人证件照
     */
    PERSONAL_ID_PHOTO(1004, "个人证件照", true, 1, "fa:address-card-o"),
    /**
     * 身份证复印件
     */
    ID_CARD_COPY(1005, "身份证复印件", true, 1, "fa:list-alt"),
    /**
     * 工资银行卡
     */
    BANK_CARD(1006, "工资银行卡", true, 1, "fa:credit-card"),
    /**
     * 获奖证书
     */
    AWARD_CERTIFICATE(1007, "获奖证书", true, 1, "fa-solid:award"),
    /**
     * 入职简历
     */
    RESUME(1008, "入职简历", true, 1, "fa:file-text-o"),
    /**
     * 入职承诺书
     */
    INDUCTION_COMMITMENT(1009, "入职承诺书", true, 1, "fa-solid:book-open"),
    /**
     * 离职证明
     */
    SEPARATION_CERTIFICATE(1010, "上家公司离职证明", true, 1, "ep:document"),
    /**
     * 入职登记表
     */
    ENTRY_REGISTRATION_FORM(1011, "入职登记表", true, 1, "fa-solid:file-signature"),
    /**
     * 入职体检表
     */
    ENTRY_EXAMINATION_REPORT(1012, "入职体检表", true, 1, "fa:file-image-o"),
    /**
     * 保密协议
     */
    CONFIDENTIALITY_AGREEMENT(1012_1, "保密协议", true, 1, "fa:file-image-o"),
    /**
     * 其他入职资料
     */
    OTHER_ENTRY_MATERIALS(1013, "其他", true, 1, "fa-solid:th-large"),

    // ==================员工在职资料=========================
    /**
     * 劳动合同
     */
    CONTRACT_IN_SERVICE(2001, "劳动合同", true, 2, "fa-solid:file-invoice"),
    /**
     * 转正申请表
     */
    CORRECTION_APPLICATION_FORM(2002, "转正申请表", true, 2, "fa-solid:file-upload"),
    /**
     * 试用期考核表
     */
    PROBATION_ASSESSMENT_FORM(2003, "试用期考核表", true, 2, "fa-solid:file-alt"),
    /**
     * 低绩效面谈表
     */
    LOW_PERFORMANCE_INTERVIEW_FORM(2004, "低绩效面谈表", true, 2, "fa:map"),
    /**
     * 晋升申请表
     */
    PROMOTION_APPLICATION_FORM(2005, "晋升申请表", true, 2, "fa:signal"),
    /**
     * 晋升申请表
     */
    PROMOTION_APPLICATION_FORM_ADMIN(2005_1, "晋升申请表-管理端补充", false, 2, "fa:signal"),
    /**
     * 调岗申请表
     */
    TRANSFER_APPLICATION_FORM(2006, "调岗申请表", true, 2, "fa:share-square"),
    /**
     * 调岗申请表
     */
    TRANSFER_APPLICATION_FORM_ADMIN(2006_1, "调岗申请表-管理端补充", false, 2, "fa:share-square"),
    /**
     * 岗位确认书
     */
    POSITION_CONFIRMATION_FORM(2007, "岗位确认书", true, 2, "fa-solid:book-reader"),
    /**
     * 降级通知书
     */
    DOWNGRADE_APPLICATION_FORM(2008, "降级通知书", true, 2, "fa-solid:sort-amount-down-alt"),
    /**
     * 降级通知书
     */
    DOWNGRADE_APPLICATION_FORM_ADMIN(2008_1, "降级通知书-管理端补充", false, 2, "fa-solid:sort-amount-down-alt"),
    /**
     * 其他在职资料
     */
    OTHER_IN_SERVICE_CONTRACT(2009, "合同其他资料", false, 2, ""),
    OTHER_IN_SERVICE_REGULARIZE(2010, "转正其他资料", false, 2, ""),
    OTHER_IN_SERVICE_CHANGEPOST(2011, "调动:调岗其他资料", false, 2, ""),
    OTHER_IN_SERVICE_PROMOTED(2012, "调动:晋升其他资料", false, 2, ""),
    OTHER_IN_SERVICE_DEGRADE(2013, "调动:降级其他资料", false, 2, ""),
    OTHER_IN_SERVICE_EMPLOYEES(2015, "其他", true, 2, "fa-solid:th-large"),

    // ==================员工离职资料=========================
    /**
     * 离职申请书
     */
    SEPARATION_APPLICATION_FORM(3001, "离职申请书", true, 3, "fa-solid:file-export"),
    /**
     * 离职承诺书
     */
    SEPARATION_COMMITMENT(3002, "离职承诺书", true, 3, "fa-solid:file-archive"),
    /**
     * 离职协议
     */
    SEPARATION_AGREEMENT(3003, "离职协议", true, 3, "fa-solid:file-alt"),
    /**
     * 工作交接
     */
    WORK_HANDOVER(3003_1, "工作交接", true, 3, "fa-solid:file-alt"),
    /**
     * 其他离职资料
     */
    OTHER_SEPARATION_MATERIALS(3004, "其他", true, 3, "fa-solid:th-large"),

    ;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BizFileTypeEnum::getCode).toArray();

    private final Integer code;

    private final String name;
    // 是否显示在页面
    private final Boolean isShow;
    // 类型
    private final Integer type;

    private final String icon;

    @Override
    public int[] array() {
        return ARRAYS;
    }


    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public Integer getType() {
        return type;
    }

    public String getIcon() {
        return icon;
    }


    /**
     * 根据code返回desc
     *
     * @param type 类型
     * @return 名称
     */
    public static List<Integer> getCodeByType(Integer type) {
        List<Integer> result = new ArrayList<>();
        for (BizFileTypeEnum e : BizFileTypeEnum.values()) {
            if (e.getType().equals(type)) {
                result.add(e.getCode());
            }
        }
        return result;
    }

    /**
     * 根据code返回icon
     *
     * @param code 类型
     * @return 名称
     */
    public static String getIconByCOde(Integer code) {
        for (BizFileTypeEnum e : BizFileTypeEnum.values()) {
            if (e.getCode().equals(code)) {
                return e.getIcon();
            }
        }
        return null;
    }
    /**
     * 根据code返回是否显示
     *
     * @param code 类型
     * @return 名称
     */
    public static Boolean isShow(Object code) {
        for (BizFileTypeEnum e : BizFileTypeEnum.values()) {
            if (e.getCode().equals(code)) {
                return e.getIsShow();
            }
        }
        return false;
    }
    /**
     * 根据code返回name
     *
     * @param code 类型
     * @return 名称
     */
    public static String getName(Object code) {
        for (BizFileTypeEnum e : BizFileTypeEnum.values()) {
            if (e.getCode().equals(code)) {
                return e.getName();
            }
        }
        return null;
    }
}
